<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\Status;
//use App\Http\Requests;
use Illuminate\Support\Facades\Auth;
class StatusesController extends Controller
{
    //权限

    public function __construct()
    {
        $this->middleware('auth');

    }

    //发布微博
    public function store(Request $request)
    {
       //验证大小
       $this->validate($request,[
         'content'=>'required|max:140',
       ]);
      //创建❤内容
      Auth::user()->statuses()->create([
        'content'=>$request->content
      ]);

     return redirect()->back();
    }
   //删除微博
   public function destroy(Status $status)
   {
    $this->authorize('destroy',$status);
    $status->delete();
    session()->flash('success','微博已被成功删除');
    return redirect()->back();
   }




}
